<?php

namespace support;

use Workerman\Worker;

class SqlDebug implements \Webman\Bootstrap
{
    /**
     * @inheritDoc
     */
    public static function start(?Worker $worker)
    {
        //echo "\n start getenv('DEBUG'):" . getenv('DEBUG');
        if (getenv('DEBUG')) {
            //echo "\n  debug is true";
            \think\facade\Db::listen(function ($sql, $runtime, $master) {
                // 进行监听处理
                $sql = "[sql] " . $sql . " [runtime] " . $runtime . " master:" . print_r($master, true);
                \app\common\util\YcLog::info($sql);
            });
        }
    }
}
